package com.bloody.android.Characters;

import com.bloody.android.R;
import com.bloody.android.ViewObject;
import com.bloody.android.R.drawable;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.Log;

public abstract class ViewCharacter extends ViewObject{
	
	private Character character;
	private Bitmap blue;
	private Drawable tileBlue;
	
	public ViewCharacter(Context context, int id, Character ch) {
		super(context, id);
		character = ch;
		Resources r = context.getResources();
		tileBlue = r.getDrawable(R.drawable.hasplayed);
	}
	
	public int getPosx(){
		return character.getPosx();
	}
	
	public int getPosy(){
		return character.getPosy();
	}
	
	public void createIm(int tileSize){
		super.createIm(tileSize);

        blue = Bitmap.createBitmap(tileSize, tileSize, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(blue);
        tileBlue.setBounds(0, 0, tileSize, tileSize);
        tileBlue.draw(canvas);
	}
	
	public void draw(Canvas canvas, int mXOffset, int mYOffset, int mTileSize, Paint mPaint, int xmin, 
			int xmax, int ymin, int ymax){
		
		int posx = getPosx();
		int posy = getPosy();
		
		if(posx>=xmin && posx<=xmax && posy>=ymin && posy<=ymax){
	
			if (character.isAlive())
				super.draw(canvas, mXOffset, mYOffset, mTileSize, mPaint, xmin, xmax, ymin, ymax);
			if(character.getHasPlayed())
				super.draw(blue, canvas, mXOffset, mYOffset, mTileSize, mPaint, xmin, xmax, ymin, ymax);
		}
	}

}